<%@ taglib prefix="uthink" uri="/WEB-INF/tld/shiros.tld" %>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet"
	type="text/css" />
<link href="css/pagination.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>商户管理</title>
<style>
.title {
	display: block;
	background: #5a98de;
	line-height: 31px;
	float: left;
	color: white;
	width: 95px;
	text-align: center;
}

.title:hover {
	text-decoration: none;
	color: white;
}
</style>
</head>
<body>
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 商家中心 <span class="c-gray en">&gt;</span> 商户管理 

		<a class="btn btn-success btn-refresh radius r mr-20"
			style="line-height:1.6em;margin-top:3px"
			onclick="javascript:location.replace(location.href);"
			href="javascript:location.replace(location.href);" title="刷新">刷新</a>
		<a class="btn btn-primary radius r mr-20 mt-5" onclick="shop_add('添加商户','<%=path%>/backstage/shop-add-pre')"
				href="javascript:;"> 添加商户</a>
	</nav>
	<div class="pd-20">
		<div class="cl pd-5 bg-1 bk-gray">
			<a id="all" style="border-top-left-radius:5px;border-bottom-left-radius:5px;" class="title">全部</a>
			<a id="enable" style="border-top-right-radius:5px;border-bottom-right-radius:5px;margin-right:80%;" class="title">正在审核</a>
	
		</div>
		<div class="cl pd-5 bg-1 bk-gray" style="margin-top:20px;">

			<form action="<%=path%>/backstage/shop-condition" method="post"
				class="form form-horizontal" id="search-form">
				<div class="text-c">
				<div class="row cl">
					<label class="form-label col-1">店铺名：</label>
					<div class="formControls col-2">
						<input type="hidden" value="${cond.status }" name="status" id="status">
						<input type="text" value="${cond.name }" name="name" id="name" placeholder="店铺名" class="input-text">
					</div>

					<label class="form-label col-1">联系人：</label>
					<div class="formControls col-2">
						<input type="text" value="${cond.c_contacts }" name="c_contacts" id="person" placeholder="联系人" class="input-text">
					</div>
					<label class="form-label col-1">品类：</label>
					<div class="formControls col-2">
						<span class="select-box"> <select name="type"
							class="select">
								<option value="">默认</option>
								<c:forEach items="${types}" var="type">
									<option value="${type.cCode}"
										<c:if test="${type.cCode==cond.type}">selected</c:if>>${type.cName}</option>
								</c:forEach>
						</select>
						</span>
					</div>
					<label class="form-label col-1">地址：</label>
					<div class="formControls col-2">
						<input type="text" value="${cond.address }" name="address" id="address" placeholder="地址" class="input-text">
					</div>
					</div>
					<div class="row cl">
					<label class="form-label col-1">店铺ID：</label>
					<div class="formControls col-2">
						<input type="text" value="${cond.id }" name="id" id="id" placeholder="店铺ID" class="input-text">
					</div>
					<label class="form-label col-1">联系电话：</label>
					<div class="formControls col-2">
						<input type="text" value="${cond.phone }" name="phone" id="phone" placeholder="联系电话" class="input-text">
					</div>
					<label class="form-label col-1">结款方式：</label>
					<div class="formControls col-2">
						<span class="select-box"> <select name="cashType"
							class="select">
								<option value="" >默认</option>
								<option value="预付" <c:if test="${cond.cashType == '预付'}">selected="selected"</c:if>>预付</option>
								<option value="现结算" <c:if test="${cond.cashType == '现结算'}">selected="selected"</c:if>>现结算</option>
								<option value="周结算" <c:if test="${cond.cashType == '周结算'}">selected="selected"</c:if>>周结算</option>
								<option value="月结算" <c:if test="${cond.cashType == '月结算'}">selected="selected"</c:if>>月结算</option>
						</select>
						</span>
					</div>
					</div>
					<div class="row cl">
					<button name="" id="" class="btn btn-success" style="border-radius:5px;float:right;" type="submit">
						 查询
					</button>
					<div style="width:10px;height:5px;float:right;"></div>
					<button name=""  onclick="theReset();" id="" class="btn btn-success" style="border-radius:5px;float:right;" type="reset">
						 重置
					</button>
					</div>
				</div>
			</form>

		</div>

		<div class="mt-20">
			<table
				class="table table-border table-bordered table-hover table-bg table-sort">
				<thead>
					<tr class="text-c">
						<th width="40">ID</th>
						<th>商户名称</th>
						<th>联系人</th>
						<th>Logo</th>
						<th>地址</th>
						<th width="80">所属分类</th>
						<th width="80">所属县市</th>
						<th width="60">状态</th>
						<th>申请时间</th>
						<th width="120">操作</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${shops}" var="shop">
						<tr class="text-c">
							<input type="hidden" id="cId" name="cId" value='${shop.cId}' />
							<td>${shop.cId}</td>
							<td>${shop.cSname}</td>
							<td>${shop.c_contacts}</td>
							<td><img src="<%=imagePath%>${shop.cLogo}" height="30" border="0" /></td>
							<td>${shop.cAddress}</td>
							<td>
								<c:forEach items="${types}" var="type">
									<c:if test="${type.cCode==shop.cType}">
										${type.cName}
									</c:if>
								</c:forEach>
							</td>
							<td><c:forEach items="${citys}" var="city">
									<c:if test="${city.id==shop.c_city_id}">
									${city.name}
								</c:if>
								</c:forEach></td>
							<td class="td-status"><c:choose>
									<c:when test="${1==shop.is_out}">
										<span class="label label-danger radius">已下架</span>
									</c:when>
									<c:when test="${1==shop.cEnable}">
										<span class="label label-success radius">已通过</span>
									</c:when>
									<c:when test="${0==shop.cEnable}">
										<span class="label label-danger radius">未通过</span>
									</c:when>
									<c:otherwise>
										<span class="label label-warning radius">未审核</span>
									</c:otherwise>
								</c:choose></td>
							<td>${fn:split(shop.appdate,'.')[0]}</td>
							<td class="td-manage">
							
							<uthink:permission module="shops" code="shop-edit">
							<a style="text-decoration:none"
								onClick="shop_edit(this,'${shop.cId}')" href="javascript:;"
								title="编辑">编辑 &nbsp;&nbsp; 
							</uthink:permission>
							
							<uthink:permission module="shops" code="shop_enable">
								<c:if test="${1!=shop.cEnable}">		
									<a style="text-decoration:none"
									onClick="shop_enable(this,'${shop.cId}')" href="javascript:;"
									title="审核">审核</a>&nbsp;&nbsp;
								</c:if> 
							</uthink:permission>
								<a style="text-decoration:none"
									onClick="shop_del(this,'${shop.cId}')" href="javascript:;"
									title="查看">查看</a>
								<c:if test="${shop.is_ziying!=1}">	<!--  添加非自营商店商品  -->
								    <a style="text-decoration:none"
										onclick="goods_add('添加商品','<%=path%>/backstage/add-shop-goods?shopId=${shop.cId}')" href="javascript:;"
										title="添加商品">添加商品</a>
								 </c:if>
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<div id="Pagination" class="page-con"></div>
		</div>
	</div>
	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script>
	<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="js/jquery.pagination.js"></script>
	<script type="text/javascript"
		src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="js/H-ui.js"></script>
	<script type="text/javascript" src="js/H-ui.admin.js"></script>
	<script type="text/javascript">
		$(function() {
			initPager();
		});
		
		var showCount = ${pageInfo.showCount};
		var currentPage = ${pageInfo.currentPage-1};
		var totalResult = ${pageInfo.totalResult};
		function initPager(){
			$("#Pagination").pagination(totalResult, {
	            callback: function(new_page_index, pagination_container){
	            	var oldLocation = location.href;
	            	var pa = "currentPage=" + (new_page_index+1);
	        		var shoC = "showCount=" + showCount;
	            	var index = oldLocation.lastIndexOf("?");
	            	if (index == -1){
	            		location.href = oldLocation + "?" + pa + "&" + shoC;
	            	}else if (oldLocation.indexOf("currentPage") == -1){
	            		location.href = oldLocation + "&" + pa;
	            	}else if (oldLocation.indexOf("showCount") == -1){
	            		location.href = oldLocation + "&" + shoC;
	            	}else{
	            		var temp = oldLocation.replace(/currentPage=\d+/, pa);
						var newLocation = temp.replace(/showCount=\d+/, shoC);
	            		location.href = newLocation;
	            	}
	            	return false;
	            },
	            items_per_page:showCount, 
	            load_first_page:false,
	            prev_text:'上一页',
	            next_text:'下一页',
	            ellipse_text:'...',
	            num_edge_entries:1,
	            num_display_entries:5,
	            current_page:currentPage
	        });
		}
	
		/* $(function() {
			$('.table-sort').dataTable({
				"aaSorting" : [ [ 0, "desc" ] ],//默认第几个排序
				"bStateSave" : true,//状态保存
				"aoColumnDefs" : [
				//{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
				{
					"orderable" : false,
					"aTargets" : [ 1, 2 ]
				} // 制定列不参与排序
				]
			});
			$('.table-sort tbody').on('click', 'tr', function() {
				if ($(this).hasClass('selected')) {
					$(this).removeClass('selected');
				} else {
					table.$('tr.selected').removeClass('selected');
					$(this).addClass('selected');
				}
			});
		}); */
		
		/*添加*/
		function shop_add(title,url){
			var index = layer.open({
				type: 2,
				title: title,
				content: url
			});
			layer.full(index);
		}
		
		/*添加商品*/
		function goods_add(title,url){
			var index = layer.open({
				type: 2,
				title: title,
				content: url
			});
			layer.full(index);
		}
		
		
		/*编辑*/
		function shop_edit(obj,id,w,h){
			var edit_page = "<%=path%>/backstage/shop-add-pre?id="+id;
			var index = layer.open({
				type: 2,
				title: "编辑",
				content: edit_page
			});
			layer.full(index);
		}
		
		/*
		重置
		*/
		function theReset(){
			/* debugger;
			$("#search-form input[type='text']").val('');
			$("#search-form select").val(-1);
			$("#endType").val("-1"); */
			$(".btn-refresh").click();
		}
		
		/*查看*/
		function shop_del(obj,id,w,h){
			var edit_page = "<%=path%>/backstage/shop-del-pre?id="+id;
			var index = layer.open({
				type: 2,
				title: "查看",
				content: edit_page
			});
			layer.full(index);
		}
		/*审核*/
		function shop_enable(obj,id){
			layer.confirm('审核商户?', {
				btn: ['通过','不通过'], 
				shade: false,
				closeBtn : false
			},function(){
				$.ajax({
					type : "POST",
					url : "<%=path%>/backstage/shop-enable",
					data : {
						c_id:id,
						enable:"1"
					},
					error : function() {
						layer.msg('操作失败', {
							icon : 5,
							time : 1000
						});
					},
					success : function(msg) {
						$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已审核</span>');
						$(obj).remove();
						layer.msg('已审核', {
							icon : 6,
							time : 1000
						});
					}
				});
				}, function() {
					$.ajax({
					type : "POST",
					url : "<%=path%>/backstage/shop-enable",
					data : {
						c_id:id,
						enable:"0"
					},
					error : function() {
						layer.msg('操作失败', {
							icon : 5,
							time : 1000
						});
					},
					success : function(msg) {
						$(obj).parents("tr").find(".td-status").html('<span class="label label-danger radius">未通过</span>');
						$(obj).remove();
						layer.msg('未通过', {
							icon : 5,
							time : 1000
						});
					}
				});
			});
		}
		if($("#status").val()==1){
			$("#all").css({"background":"#5a98de","border":"1px solid #5a98de"});
			$("#enable").css({"background":"white","border":"1px solid black","color":"black"});
		}else if($("#status").val()==0){
			$("#enable").css({"background":"#5a98de","border":"1px solid #5a98de"});
			$("#all").css({"background":"white","border":"1px solid black","color":"black"});
		}else{
			$("#all").css({"background":"#5a98de","border":"1px solid #5a98de"});
			$("#enable").css({"background":"white","border":"1px solid black","color":"black"});
		}
		//$("#enable").css({"background":"#429842"});
		
		//选择店铺状态
		$("#all").click(function(){
			$("#status").val(1);
			$("#form-goods-add").submit();
			$("#all").css({"background":"#5a98de","border":"1px solid #5a98de"});
			$("#enable").css({"background":"white","border":"1px solid black","color":"black"});
		});
		
		//选择店铺状态
		$("#enable").click(function(){
			$("#status").val(0);
			$("#form-goods-add").submit();
			$("#enable").css({"background":"#5a98de","border":"1px solid #5a98de"});
			$("#all").css({"background":"white","border":"1px solid black","color":"black"});
		});

		/*图片-下架*/
		function product_stop(obj, id) {
			layer.confirm('确认要下架吗？',
				function(index) {
				$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="product_start(this,id)" href="javascript:;" title="发布"><i class="Hui-iconfont">&#xe603;</i></a>');
				$(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已下架</span>');
				$(obj).remove();
				layer.msg('已下架!', {
					icon : 5,
					time : 1000
				});
			});
		}
	</script>
</body>
</html>